The present invention relates to a device for processing data in a data block unit configured by obtaining a data group containing one or more pieces of data, and furthermore containing multiple data groups, and more specifically to a block-floating-point type digital signal processor (hereinafter referred to as a DSP for short) for performing a fixed-point calculation in a block-floating-point system.
There is fixed-point representation or floating-point representation as a method of representing a value in a digital signal processing.
In the floating-point representation, each piece of data has an exponent and a mantissa, thereby guaranteeing high precision and a wide dynamic range. However, it also has a problem of requiring complicated and large-scale hardware.
On the other hand, in the fixed-point representation, only simple and small-scale hardware is required, but there is a problem of the degradation in calculation precision. FIG. 10 shows an example of a typical conventional fixed-point type DSP. FIG. 10 actually shows a configuration of a conventional fixed-point type DSP, and the number of bits of the data in the input/output stage of each component.
As shown in FIG. 10, the conventional fixed-point type DSP includes a data memory 100 for storing data in n bit length, a multiply-accumulate operation unit 12 for receiving n bit data from the data memory 100 and outputting 2n bit calculated data, a selection circuit 13 for selecting higher n bit data from the 2n bit calculated data, and a data bus 110. The DSP reads data which is to be computed from the data memory 100, calculates the read data in the multiply-accumulate operation unit 12, selects by the selection circuit 13 the higher n bit data from the calculated data received from the multiply-accumulate operation unit 12, and stores again the calculated data from the selection circuit 13 in the data memory 100.
The multiply-accumulate operation unit 12 includes a first register file 12a for holding data from the data memory 100, a multiplier 12b for multiplying the data from the first register file 12a, an adder 12c for adding the multiplied data from the multiplier 12b to sum data obtained up to this time, and a register file 12d for holding the sum data from the adder 12c as calculated data.
The degradation of the calculation precision occurs by truncation of the lower n bits when the selection circuit 13 selects the n bits from the 2n bits.
The degradation of the calculation precision in the fixed-point representation is explained by using the following equations (1) and (2). That is, the multiply-accumulate operation unit 12 performs operations by the following equations (1) and (2).
For simple explanation, the data from the data memory 100 is taken as 8 bits, the output from the multiply-accumulate operation unit 12 as 16 bits, and the data X(0) to X(7) and the coefficient data A(0) to A(3), B(0), and B(1) are provided for calculation for the multiply-accumulate operation unit 12. The data X(0) to X(7) and the coefficient data A(0) to A(3), B(0), and B(1) respectively have the values as shown in FIG. 11, and X(xe2x88x923)=X(xe2x88x922)=X(xe2x88x921)=Y(xe2x88x921)=0. Furthermore, as shown in FIG. 12, the most significant bits (MSB) of each data and coefficient data are sign bits, and a binary point is placed between the sign bit and a right adjacent bit. The right adjacent bit of the sign bit has significance of 0.5, and the decimal representation of the values of each piece of data and coefficient data is shown in FIG. 11.
FIG. 13 shows an operation result obtained when an operation is performed by the following equations (1) and (2) using the conventional fixed-point type DSP. FIG. 13 also shows an operation result (binary representation and decimal representation) finally stored in the data memory 100, the output (16-bit binary representation) of the multiply-accumulate operation unit 12 as an intermediate result, and an operation result obtained when an operation is performed using a floating-point for comparison. Since the data of lower 8 bits is lost when 8 bits are selected from 16 bits, the precision is lowered. A signal-to-noise ratio (SNR) is introduced as a scale indicating the amount of degradation in precision, and is defined by the following equation (3).
The following equation (3) shows an operation performed by dividing a sum of squares of a result of a floating-point operation result by a sum of squares of an error (difference between a result of a fixed-point operation and a result of a floating-point operation). A smaller value indicates lower precision. When the SNR is computed using the result shown in FIG. 13, the result is obtained by the following equations (4) and (5). The following equation (4) shows the SNR based on the operation result of the following equation (1). The following equation (5) shows the SNR based on the operation result of the following equation (2).
Thus, in the fixed-point representation, the precision considerably drops with the repetition of continuous operations.
The block-floating-point system has been developed to solve the above mentioned problem. In this system, a predetermined number (m, for example) of pieces of data is defined as a data block, a block scale factor is assigned to one data block, and a joint scaling (hereinafter referred to as block normalization) is performed on pieces of data in the data block, thereby reducing the degradation in precision by effectively using a limited dynamic range.
To efficiently realize the block-floating-point, for example, a DSP as shown in FIG. 14 is suggested (Japanese Patent Laid-Open No. 10-40073).
In addition to the configuration of the above mentioned conventional fixed-point type DSP, the block-floating-point type DSP includes, as shown in FIG. 14, the second shifter 10 for block-normalizing the input data to the multiply-accumulate operation unit 12 based on a given scale factor; a block scale factor detector 54 for detecting a block scale factor based on each piece of the data contained in the data block; and a block scale factor register 56 storing the block scale factor.
The block scale factor detector 54 receives the calculated data from the selection circuit 13, detects the data whose absolute value is the largest in all data of the data block, and the detected number of redundant bits is detected as a block scale factor.
When a second shifter 10 receives the block scale factor of the block scale factor register 56 from the control device not shown in the drawings, the second shifter 10 shifts bits by the amount corresponding to the block scale factor to the higher bit direction for each piece of data of the data block (hereinafter, referred to as left shift).
Next, the operations performed when the following equations (1) and (2) are used in the above mentioned conventional block-floating-point type DSP are described below.
First, the number of pieces of data contained in the data block is defined as a xe2x80x98block sizexe2x80x99, and a series of processes in which each piece of data in the data block is read from the data memory 100, a multiply-accumulate operation is performed on the data, and then the calculated data which is an operation result is stored in the data memory 100 again are defined as xe2x80x98block processesxe2x80x99.
In the following equations (1) and (2), an operation is performed by the following equation (1) with the block size of 8 and an input of the data blocks X(0) to X(7) in the first block process to obtain Y(0) to Y(7), and an operation is performed by the following equation (2) with the block size of 8 and an input of the data blocks Y(0) to Y(7) in the second block process to obtain Z(0) to Z(7). In the first block process, since the block scale factor of 0 is set in the block scale factor register 56, the block normalizing process is not performed by the second shifter 10. In the following description, the method of setting the coefficient data A(0) to A(3), B(0), and B(1) is not specifically explained, but can be read from the data memory 100 as necessary.
In the first step, the following process is performed for n=0 to 7. Data X(n), X(n-1), X(n-2) is sequentially read from the data memory 100, and input to the second shifter 10. In the first block process, since the block scale factor of the block scale factor register 56 is O, the block normalizing process is not performed by the second shifter 10, and X(n), X(n-1), X(n-2) is input as is to the multiply-accumulate operation unit 12. The multiply-accumulate operation unit 12 performs an operation by the following equation (1), and input the calculated data to the selection circuit 13. The selection circuit 13 selects and retrieves the higher n bits from the calculated data. The n-bit calculated data from the selection circuit 13 is stored in the data memory 100 as Y(n) through the data bus 110. On the other hand, in parallel with the storing process, the calculated data Y(n) is input to the block scale factor detector 54 to determine the block scale factor used in the second block process.
When the process in the first step is completed, the block scale factor detector 54 determines in the second step the block scale factor used in the second block process, and stores the determined block scale factor in the block scale factor register 56.
Then, in the third step, the following process is performed for n=0 to 7. The data Y(n), Y(n-1) is sequentially read from the data memory 100, and is input to the second shifter 10. The second shifter 10 performs the block normalizing process based on the block scale factor of the block scale factor register 56, and inputs the block-normalized data to the multiply-accumulate operation unit 12. The multiply-accumulate operation unit 12 performs an operation by the following equation (2), and inputs the calculated data to the selection circuit 13. The selection circuit 13 selects and retrieves the higher n bits from the calculated data. The n-bit calculated data from the selection circuit 13 is stored in the data memory 100 as Z(n) through the data bus 110. On the other hand, in parallel with the storing process, the calculated data Z(n) is input to the block scale factor detector 54 to determine the block scale factor used in the third block process.
When the process in the third step is completed, the block scale factor detector 54 determines in the fourth step the block scale factor used in the third block process, and stores the determined block scale factor in the block scale factor register 56.
FIG. 15 shows the operation result of the actual block-floating-point process performed by the following equations (1) and (2) after the above mentioned processes in steps 1 to 4. When the SNR is computed by the following equation (3) using the operation result, the operations are expressed by the following equations (6) and (7). The following equation (6) shows the SNR based on the operation result of the following equation (1). The following equation (7) shows the SNR based on the operation result of the following equation (2).
According to the following equations (6) and (7), the precision is furthermore improved than by simply performing the fixed-point calculation.
As shown in the above mentioned example, the conventional block-floating-point type DSP can furthermore improve the calculation precision than the conventional fixed-point type DSP, but there still remains the problem in calculation precision.
That is, since the above mentioned conventional block-floating-point type DSP cannot determine the block scale factor until the end of the block process, the selection circuit 13 selects the higher n bits, stores them in the data memory 100, and left-shifts the calculated data by the amount of the shift corresponding to the block scale factor. Therefore, the number of lower bits corresponding to the block scale factor in the data from the second shifter 10 is 0, which carries no information.
FIG. 16 shows the comparison between the ideal data and the conventional data obtained after performing a block normalizing process on the assumption that the calculated data from the multiply-accumulate operation unit 12 is 16 bits, the data from the data memory 100 is 8 bits, the calculated data is xe2x80x9800001101 11010101xe2x80x99, and the block scale factor determined after the block process has been performed is xe2x80x982xe2x80x99. In this example, the lower 2 bits of the block-normalized data are to be ideally xe2x80x9811xe2x80x99, but the conventional DSP actually indicates xe2x80x9800xe2x80x99. This is a factor that hinders the calculation precision from being improved.
The present invention has been developed to solve the above mentioned problems of the conventional technology, and aims at providing a data calculating device applicable to improve the calculation precision when a fixed-point calculation is performed by the block-floating-point system.
The present invention further divides a data block, which is a data segment in conventional technology, by introducing a data group which is a new segment. That is, a data block is configured by including multiple data groups while a data group is configured by including one or more pieces of data. The number of pieces of data contained in a data group is defined as a xe2x80x98group sizexe2x80x99.
To attain the above mentioned purpose, the date calculating device of the present invention has a data group containing one or more pieces of data, and processes the data in a data block form containing multiple data groups. The device performs for each data group of the data block a series of processes of performing an operation on each piece of data of the data group, detecting the scale factor of a piece of calculated data having the largest absolute value in the calculated data as a group scale factor, and performing a scaling on each piece of the calculated data based on the detected group scale factor, detects a group scale factor corresponding to the calculated data having the largest absolute value in the detected group scale factors as a block scale factor, and performs a scaling on each piece of the calculated data of the data group based on the group scale factor of the data group and the block scale factor before performing an operation on the scaled calculated data if the operation is performed again.
With the above mentioned configuration, an operation is performed on each piece of data of the data group, the scale factor of the calculated data having the largest absolute value is detected as a group scale factor, and a scaling is performed on each piece of the calculated data based on the detected group scale factor. The series of processes are performed for each data group of the data block. When the processes are completed for one data block, the group scale factor corresponding to the calculated data having the largest absolute value in the group scale factors detected for the respective data groups is detected as a block scale factor.
When the operation is performed again on the scaled calculated data, the device performs the scaling on each piece of the calculated data of the data group based on the group scale factor of the data group and the block scale factor.
Afterwards, the operation is performed on each piece of the scaled calculated data, the scale factor of the calculated data having the largest absolute value in the calculated data is detected as a group scale factor, and a scaling is performed on each piece of calculated data based on the detected group scale factor. The series of processes are performed on each data group in a data block. When the processes are completed for one data block, a group scale factor having the largest absolute value in the group scale factors detected for the respective data groups is detected as a block scale factor.
A scale factor can be, for example, the amount of the shift in the bit shift of data. In this case, a scaling is performed by shifting bits for data by the amount of the shift corresponding to the scale factor.
The configuration for detecting a group scale factor can be designed such that after performing an operation on each piece of data in a data group, a scale factor of the calculated data can be computed, and the smallest scale factor in the computed scale factors can be detected as a group scale factor, or a group scale factor can be detected directly from the calculated data without computing the scale factors of the calculated data.
Furthermore, the data calculating device of the present invention, performs the scaling on each piece of the calculated data of the data group based on the difference between the group scale factor of the data group and the block scale factor before performing the operation when the operation is performed again on the scaled calculated data.
With the configuration, when the operation is performed again on the scaled data, a scaling is performed on each piece of the calculated data in the data group based on the difference between the group scale factor of the data group and the block scale factor.
Furthermore, the data calculating device of the present invention also includes multiple calculation units, and processes data in a data block form containing multiple data groups, the data group including one or more pieces of data. Each of the calculation units includes: first scaling means for scaling data based on a given scale factor; operation means for performing an operation on data from the first scaling means; scale factor computation means for computing a scale factor of the calculated data from the operation means; and second scaling means for scaling the calculated data from the operation means based on another given scale factor. The device further includes: storage means for storing data; group scale factor detection means for detecting a scale factor corresponding to the calculated data having the largest absolute value in the scale factors computed by the scale factor computation means of each calculation unit as a group scale factor; block scale factor detection means for detecting a group scale factor corresponding to the calculated data having the largest absolute value in the group scale factors detected by the group scale factor detection means as a block scale factor; and control means for performing control for data processing. The control means reads data from the storage means in a data block unit, and for each data group of the data block, allots the data of the data group to the first scaling means of each of the calculation units, assigns the group scale factor detected by the group scale factor detection means to the second scaling means of each of the calculation units, and stores the calculated data from the second scaling means of each of the calculation units in the storage means, and when the operation is performed again on the calculated data in the storage means, the control means, for each data group of the data block, allots the calculated data of the data group to the first scaling means of each of the calculation units, and assigns a scale factor obtained as a difference between the group scale factor of the data group and the block scale factor to the first scaling means of each of the calculation units.
With the configuration, the control means reads data in a data block unit from the storage means, and for each data group of a data block, allots the data of a data group to the first scaling means of each of the calculation units.
Since a scale factor has not been assigned to the first scaling means in the initial state in each of the calculation units, a scaling is not performed by the first scaling means, and the data is input as is to the operation means. Then, the operation means performs an operation on the data from the first scaling means, and the scale factor computation means computes a scale factor of the calculated data from the operation means.
When a scale factor is computed in each calculation unit, the group scale factor detection means detects a scale factor corresponding to the calculated data having the largest absolute value in the scale factors computed by the scale factor computation means of each calculation unit as a group scale factor, and the control means assigns the computed group scale factor to the second scaling means of each calculation unit.
Thus, in each calculation unit, the second scaling means performs a scaling on the calculated data from the operation means based on a given group scale factor.
When a scaling is performed on the calculated data in each calculation unit, the control means controls the storage means to store the calculated data from the second scaling means of each calculation unit, and the block scale factor detection means detects a group scale factor corresponding to the calculated data having the largest absolute value in the group scale factors detected by the group scale factor detection means as a block scale factor.
When the operation is performed again on the calculated data in the storage means, the control means reads the calculated data from the storage means in a data block unit, and for each data group of the data block, allots the calculated data of the data group to the first scaling means of each calculation unit, and assigns a scale factor obtained as the difference between the group scale factor of the data group and the block scale factor to the first scaling means of each calculation unit.
In each calculation unit, the first scaling means performs a scaling on the given calculated data based on the scale factor obtained as the difference between the group scale factor detected in the previous process and the block scale factor, the operation means performs an operation on the calculated data from the first scaling means, and the scale factor computation means computes the scale factor of the calculated data from the operation means.
When a scale factor is computed in each calculation unit, the group scale factor detection means detects a scale factor corresponding to the calculated data having the largest absolute value in the scale factors computed by the scale factor computation means of each calculation unit is detected as a group scale factor, and the control means assigns the computed group scale factor to the second scaling means of each calculation unit.
Thus, in each calculation unit, the second scaling means performs a scaling on the calculated data from the operation means based on the assigned group scale factor.
When a scaling is thus performed on the calculated data in each calculation unit, the control means controls the storage means to store the calculated data from the second scaling means of each calculation unit, and the block scale factor detection means detects a group scale factor corresponding to the calculated data having the largest absolute value in the group scale factors detected by the group scale factor detection means as a block scale factor.
The storage means only has to store data, store data in advance, or store data when the present device is operated.
The scale factor can be, for example, the amount of the shift in the bit shift of data. In this case, a scaling is performed by shifting bits for data by the amount of the shift corresponding to the scale factor.
Furthermore, the data calculating device of the present invention, further includes second storage means for storing the group scale factor and the block scale factor, the control means associates the group scale factor and the block scale factor with calculated data, and stores them in the second storage means, and when the operation is performed again on the calculated data in the storage means, the control means reads the corresponding group scale factor and block scale factor from the second storage means, and for each data group of the data block, allots the calculated data of the data group to the first scaling means of each calculation unit, and assigns the scale factor obtained as the difference between the group scale factor of the data group and the block scale factor to the first scaling means of each calculation unit.
With the configuration, when the operation is performed again on the calculated data in the storage means, the control means associates the group scale factor detected by the group scale factor detection means and the block scale factor detected by the block scale factor detection means with the calculated data from the second scaling means of each calculation unit and stores them in the second storage means.
When the operation is performed again on the calculated data in the storage means, the control means reads the corresponding group scale factor and block scale factor from the second storage means, and for each data group of the data block, allots the calculated data of the data group to the first scaling means of each calculation unit, and assigns the scale factor obtained as the difference between the group scale factor of the data group and the block scale factor to the first scaling means of each calculation unit.
Thus, in each calculation unit, the first scaling means performs a scaling on the given calculated data based on the scale factor obtained as the difference between the group scale factor detected in the previous process and the block scale factor.
The second storage means stores a group scale factor and a block scale factor. It is not necessary for the second storage means to store them in advance.
Furthermore, according to the data calculating device of the present invention, the scale factor computation means computes the number of redundant bits of the calculated data from the operation means, and outputs it as a scale factor.
With the configuration, the scale factor computation means computes the number of redundant bits of the calculated data from the operation means, and computes it as a scale factor.
Furthermore, according to the data calculating device of the present invention, the operation is a fixed-point operation unit, the first scaling means shifts bits for the data by the amount of the shift corresponding to a given scale factor, and the second scaling means shifts bits for the calculated data from the operation means by the amount of the shift corresponding to another given scale factor.
With the configuration, in each calculation unit, the first scaling means shifts bits for given data by the amount of the shift corresponding to the assigned scale factor, and the operation means performs a fixed-point calculation on the data from the first scaling means. Then, the second scaling means shifts bits on the calculated data from the operation means by the amount of the shift corresponding to the assigned scale factor.
The first scaling means shifts bits for data, for example, in the lower bit direction (hereinafter referred to simply as right shift). The second scaling means, for example, left-shifts or right-shifts data.
Furthermore, according to the data calculating device of the present invention, the operation means is a multiply-accumulate operation unit for computing a sum of products of the data from the first scaling means and a predetermined coefficient.
With the configuration, the operation means computes a sum of products from the first scaling means and a predetermined coefficient, and the obtained data is output as calculated data.
The outline of the present invention is shown in FIG. 1, for example. According to the present invention, a scale factor is computed for each data group as a group scale factor, the data output from the multiply-accumulate operation unit 12 is normalized (hereinafter referred to as xe2x80x98group-normalizedxe2x80x99) with a group scale factor, and the group scale factor is associated with the group-normalized data group and stored in a group scale factor register file 52. The series of processes is repeatedly performed on other data groups contained in the data block. After performing the process on one data block, the smallest scale factor is detected from multiple group scale factors as a block scale factor, associated with the data block, and stored in the block scale factor register 56. When a block process is performed on the data block, there can be the possibility that the block scale factor is different from the group scale factor, and the positions of the digits are not aligned among data groups. Therefore, each data group is shifted (block-normalized) and aligned based on the difference between the group scale factor and the block scale factor, and then input to the multiply-accumulate operation unit 12.
Thus, the data obtained after the multiply-accumulate operation is temporarily group-normalized in a data group unit, stored in the data memory 100, and then block-normalized when it is used in the subsequent block process. Therefore, the lower bits of the block-normalized data does not contain meaningless information, thereby reducing the operation error when a fixed-point calculation is performed in the block-floating-point system.
As described above, the data calculating device has been suggested to attain the above mentioned purpose. However, the present invention is not limited to this application, and the following first to seventh data calculating devices can be suggested.
The first data calculating device is used to perform a digital signal processing, determines a common scale factor for a data group containing multiple pieces of data which can be divided into a mantissa and a scale using a scaling, groups multiple mantissas, and processes data by referring to the common scale factor. It determines the smallest value in multiple scale factors in the first data group as a group scale factor, scales each piece of data in the data group by referring to the group scale factor, stores each piece of the scaled data, associates the group scale factor uniquely with the data group and stores them, repeats the processes on the second and subsequent data groups, determines the smallest value in multiple group scale factors as a block scale factor of multiple data groups, associates the block scale factor uniquely with a data block containing the first and the subsequent data groups and stores them, and scales each piece of data in each of the data groups using an alignment scale factor obtained as the difference between each of the group scale factor and the block scale factor.
Furthermore, the second data calculating device is based on the first data calculating device, stores the multiple pieces of data scaled using the alignment scale factor as a new data block, and uniquely determines the alignment scale factor as the block scale factor.
The third data calculating device is based on any of the first and the second data calculating devices, and processes by the fixed-point data representation the data scaled using the alignment factor.
The fourth data calculating device is based on any of the above mentioned first to third data calculating devices, and stores the group scale factor with related data groups.
Furthermore, the fifth data calculating device processes digital data by a digital data processor having at least one calculation unit, a register, and memory for processing data, and includes: means for computing multiple scale factors from multiple pieces of data; means for generating scaled values from multiple pieces of data by referring to the scale factor, means for storing multiple scaled values as a data group (a set of scaled values); means for detecting the smallest scale factor (group scale factor) in the data group; means for storing the group scale factor, means for detecting the smallest scale factor (block scale factor) in multiple data groups; and means for storing the block scale factor.
Furthermore, the sixth data calculating device is based on the fifth data calculating device, and includes: means for temporarily storing the group scale factor using a register file; means for associating the temporarily stored group scale factor with a corresponding data group; and means for storing the group scale factor temporarily stored in the register file.
The seventh data calculating device is based on any of the fifth and sixth data calculating devices, and includes: means for detecting the smallest scale factor; means for counting redundant sign bits; and means for merging the information about the redundant sign bits.
The data calculating devices have been suggested as described above to attain the above mentioned purpose, but the present invention is not limited to these applications. A first storage medium can also be suggested to attain the above mentioned purpose.
The first storage medium is a computer-readable storage medium, stores a program for processing data in a unit of a data block which contains multiple data groups each containing one or more pieces of data, and the program directs a computer to function as the calculation unit, the first scaling means, the operation means, the scale factor computation means, the second scaling means, the group scale factor detection means, the block scale factor detection means, and the control means.
With the configuration, the information stored in a storage medium is read by a computer, and the operation performed by the data calculating device of the present invention can be performed when the computer functions as each of these means.